home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / sys / amiga / programmer / 5027 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.4 KB  |  41 lines

  1. Path: a1200.iaehv.nl!gertjan
  2. Newsgroups: comp.sys.amiga.programmer
  3. From: gertjan@a1200.iaehv.nl (Gertjan van Ratingen)
  4. Subject: Re: File sizes
  5. References: <4gjs20$i68@btmpjg.god.bel.alcatel.be> <642.6631T1174T964@stud.cs.uit.no>
  6. X-NewsSoftware: GRn 2.1 Feb 19, 1994
  7. MIME-Version: 1.0
  8. Content-Type: text/plain; charset=iso-8859-1
  9. Content-Transfer-Encoding: 8bit
  10. Message-ID: <gertjan.0ay2@a1200.iaehv.nl>
  11. Date: Thu, 7 Mar 96 20:15:58 +0100
  12. Organization: An Amiga node polling off InterNet Access Eindhoven 040-439436
  13.  
  14.  
  15. In article <642.6631T1174T964@stud.cs.uit.no> magneoe@stud.cs.uit.no (Magne Oestlyngen) writes:
  16. > >In article <WXQ7y*5+f@yaps.rhein.de>, arno@yaps.rhein.de (Arno Eigenwillig) writes:
  17. > >|> > What's the best way of finding out the size of a file? Do I have to use
  18. > >|> > Examine()
  19. > >..or do it in ANSI-C, by opening the file, seeking to the end of it
  20. > >and getting the number of bytes returned from fseek().
  21. > fseek() does not return the number of bytes, but 0 if all went fine, non-0 else.
  22. > Use ftell() to get the position in the file after fseek().
  23.  
  24. I do not know how well this one performs compaired to fseek()/ftell(),
  25. but how about:
  26.  
  27. #include <sys/stat.h>
  28.  
  29. struct stat stat;
  30. off_t size;
  31.  
  32. lstat(filename, &stat);
  33. size = stat.st_size;
  34.  
  35. (you people can figure out the rest of the program :-)
  36.  
  37. -- 
  38. Gertjan 'Bugs' van Ratingen  a.k.a. gertjan@a1200.iaehv.nl
  39. CD-i/Amiga Software Engineer   "Trust me, I know what I'm doing" -Sledge Hammer
  40.